feat(): 实现 SubAgent WorkerRuntime 与角色策略(#274)#295
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
/code 解决你说的review,帮我解决冲突,然后补齐测试率 |
结果已按你这条指令完成:处理 review 冲突点、补测试并推送到当前 PR 分支 已完成内容
提交信息
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
|
@xgopilot 解决当前合并冲突点 |
处理结果已完成“解决当前合并冲突点”,并已推送到当前 PR 分支 已完成内容
验证结果
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
|
/review |
|
/code 修复review |
处理结果已按“修复review”完成代码修复并推送到当前 PR 分支 已完成项
验证
提交与推送
未执行项
|
…t output contract Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
|
@xgopilot 解决冲突 |
处理结果已完成本次“解决冲突”,并已把修复推送到当前 PR 分支 已完成内容
验证
提交与推送
未执行项
|
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
|
/review |
| Error: errorText(stepErr), | ||
| } | ||
| select { | ||
| case s.events <- RuntimeEvent{ |
There was a problem hiding this comment.
emitSubAgentProgress writes directly to s.events with a partially-filled RuntimeEvent, so envelope metadata (Timestamp, PayloadVersion, and run-scoped fields like Turn/Phase) stays zero-value for progress events. Since this PR introduces a richer event envelope, this creates inconsistent event contracts across event types. Please route this through the same envelope path (emitWithEnvelope / run-scoped emitter) so metadata is consistently populated.
| if result.State == subagent.StateSucceeded { | ||
| return result, nil | ||
| } | ||
| return result, errors.New(result.Error) |
There was a problem hiding this comment.
return result, errors.New(result.Error) can return an empty-string error when result.Error is blank (possible for custom WorkerRuntime implementations). Please add a fallback error message that includes at least state/stop_reason to keep failures diagnosable.
| w.stepCount++ | ||
| delta := strings.TrimSpace(stepOutput.Delta) | ||
| if delta != "" { | ||
| w.trace = append(w.trace, delta) |
There was a problem hiding this comment.
w.trace appends every step but only the last traceWindowSize entries are ever consumed (cloneRecentTrace). With larger MaxSteps, this grows memory and allocation cost unnecessarily in the hot loop. Consider trimming in place (or using a ring buffer) when appending, so internal trace storage remains bounded.
| }, nil | ||
| } | ||
|
|
||
| // bindCapabilityToPolicy 将 capability 约束在角色策略允许的工具集合内。 |
There was a problem hiding this comment.
Capability.AllowedPaths is accepted and normalized, but never enforced in Start/bindCapabilityToPolicy (only tools are filtered). This creates a policy gap: callers can provide path boundaries that are silently ignored. Either enforce path constraints here (or at the engine boundary) or remove the field until it is enforced to avoid a false sense of confinement.
|
/code 修复review |
处理结果已按“修复review”完成修复并推送到当前 PR 分支 已完成内容
验证结果
提交与推送
未执行项
|
…y bounds Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
背景
实现 #274:引入可复用的 SubAgent WorkerRuntime 内核,建立角色策略模型,并完成 Runtime 侧工厂注册与执行入口。
本 PR 不改动现有主会话单代理 Run 主链路,仅新增可独立调用的子代理能力。
本次改动
1) 新增
internal/subagent核心模块Role、Task、Budget、Capability、Output、WorkerRuntime、FactoryRolePolicy与默认角色策略:researcher/coder/reviewerWorkerRuntime默认实现:Start / Step / Stop / Result / State / PolicydefaultEngine+WorkerFactorysummary必填2) Runtime 接入
Service增加subAgentFactory字段与默认注入SetSubAgentFactory、SubAgentFactoryRunSubAgentTasksubagent_startedsubagent_progresssubagent_completedsubagent_failedsubagent_canceled3) 测试
internal/subagent:角色策略、生命周期、错误分支、输出契约internal/runtime:工厂注册与RunSubAgentTask事件流go test ./... -count=1设计边界
Closes #274
Refs #273